{exec} = require 'child_process'

task 'build', 'Build project from src/*.coffee to lib/*.js', ->
  exec 'coffee --compile --output lib/ src/', (err, stdout, stderr) ->
    throw err if err
    console.log "[#{new Date()}] Done. #{stdout} #{stderr}"
    
task 'watch', 'Watch file changes and build the project.', ->
  exec 'coffee -w -c -o lib/ src/', (err, stdout, stderr) ->
    throw err if err
    console.log "#{stdout} #{stderr}"
    
task 'run', 'Run the application.', ->
  now = new Date()
  exec 'sudo forever -a -l /tmp/#{now.getFullYear()}-#{now.getMonth()}-#{now.getDate()}.log start server', (err, stdout, stderr) ->
    throw err if err
    console.log "[#{new Date()}] #{stdout} #{stderr}"
